package com.alameda.controller.commonback;

import com.alameda.api.commonback.CommonBackService;
import com.alameda.base.dto.CommonDTO;
import com.alameda.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 通用后端 前端控制层
 *
 * @author Lv
 * @date 2024/2/19
 */
@SuppressWarnings("all")
@Api(tags = "通用后端")
@RestController
@RequestMapping("/common_back")
public class CommonBackController {

    @Autowired
    private CommonBackService commonBackService;

    /**
     * 通用获取详情
     *
     * @param commonDTO 通用后端数据传递对象
     * @return
     */
    @ApiOperation("通用获取详情")
    @PostMapping("/get")
    public Result<?> get(@RequestBody CommonDTO commonDTO) {
        return Result.success(commonBackService.get(commonDTO));
    }

    /**
     * 通用逻辑删除
     *
     * @param commonDTO 通用后端数据传递对象
     * @return
     */
    @ApiOperation("通用逻辑删除")
    @PostMapping("/remove")
    public Result<?> remove(@RequestBody CommonDTO commonDTO) {
        return Result.success(commonBackService.remove(commonDTO));
    }
}
